<?php

namespace App\Console\Commands\Export;
use App\Enums\ExportEnum;
use App\Enums\RedisKeyEnum;
use App\Http\Controllers\Admin\ExportController;
use Illuminate\Console\Command;

class export extends Command
{
    //命令名
    protected $signature = 'task:export';

    //命令描述
    protected $description = '导出充值用户';

    public function __construct()
    {
        parent::__construct();
    }

    //业务处理
    public function handle()
    {
        //查询一条待导出记录
        $id = app('redis')->rpop(RedisKeyEnum::ADMIN_EXPORT_LOG);
        $exportLog = app('model_admin_export_log')->where('id', $id)->where('status', 0)->first();

        if ($exportLog) {
            $exportLog = $exportLog->toArray();
            $task = new ExportController();
            switch ($exportLog['data_no']) {
                case 1:
                    $task->createUserRechargeData($exportLog);
                    break;
            }
        }
    }

}